package com.yt.core.spring;

import com.yt.core.exception.CustomException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.ThrowsAdvice;

public class ServiceThrowsAdvice implements ThrowsAdvice {
	private Log log = LogFactory.getLog(ServiceThrowsAdvice.class);

	public ServiceThrowsAdvice() {
	}

	public void afterThrowing(Exception ex) {
		if(!(ex instanceof CustomException)) {
			this.log.error(ex.getMessage(), ex);
			throw new RuntimeException(ex.getMessage());
		}
	}
}
